// system include.
#include <pthread.h>
#include <thread>
#include <iostream>
#include <fstream>
#include <string.h>
// apply include.
#include <mutex>

#include "control.pb.h"
#include "localization.pb.h"
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/text_format.h>

#include <ecal/ecal.h>
#include <ecal/msg/protobuf/publisher.h>
#include <ecal/msg/protobuf/subscriber.h>

void Callback(const MowerProtoPakg::localizationGNGGA& msg) {
  printf("time:%f 纬度:%f 经度:%f\n", msg.time(), msg.latitude(),msg.longitude());
}

int main(int argc, char *argv[])
{
    eCAL::Initialize(argc, argv, "GNGGA Publisher");
    eCAL::protobuf::CSubscriber<MowerProtoPakg::localizationGNGGA> subscriber("GNGGAMessage");

    subscriber.AddReceiveCallback(std::bind(&Callback, std::placeholders::_2));

    while (eCAL::Ok()) {
        std::this_thread::sleep_for(std::chrono::milliseconds(1000));
    }

    // finalize eCAL API
    eCAL::Finalize();
}